package calbs.socket.server.decoder;/**
 * Created by zhangqin on 2017/6/27.
 */

import calbs.socket.analysis.AnalysisFactory;
import io.netty.buffer.ByteBufUtil;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import io.netty.handler.codec.MessageToMessageEncoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.util.List;

/**
 * @author 张钦
 * @create 2017-06-27 15:00
 **/
@ChannelHandler.Sharable
public class AnalysisDecoder extends MessageToMessageDecoder<String> {
    Logger logger = LoggerFactory.getLogger(AnalysisDecoder.class);
    @Override
    protected void decode(ChannelHandlerContext channelHandlerContext, String charSequence, List<Object> list) throws Exception {
        logger.info("client old message {}",charSequence);
        list.add(AnalysisFactory.analysis(charSequence,channelHandlerContext.channel()));
    }
}